class TestHelper extends GroovyTestCase {

  void testNothing() {
    
  }

  def fieldCannotBeNull(obj, field) {
    obj.setProperty(field, null)
    assertNull(obj.save())
    obj.setProperty(field, "something")
    assertNotNull(obj.save())
  }

  def fieldCannotBeEmpty(obj, field) {
    obj.setProperty(field, "")
    assertNull(obj.save())
    obj.setProperty(field, "something")
    assertNotNull(obj.save())
  }

  def fieldCanBeNull(obj, field) {
    obj.setProperty(field, null)
    assertNotNull(obj.save())
  }

  def fieldCanBeEmpty(obj, field) {
    obj.setProperty(field, "")
    assertNotNull(obj.save())
  }

  def fieldLengthInvalid(obj, field, size) {
    obj.setProperty(field, stringOfLength(size))
    assertNull(obj.save())
  }

  def fieldLengthValid(obj, field, size) {
    obj.setProperty(field, stringOfLength(size))
    assertNotNull(obj.save())
  }

  def stringOfLength(length) {
    def s = ""
    (0..<length).each {
      s <<= "a"
    }
    return s.toString()
  }
  
}